<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"
    />
    <title><%= title %></title>
    <link
      rel="stylesheet"
      href="/plugins/bootstrap/dist/css/bootstrap.min.css"
    />
    <link rel="stylesheet" href="/stylesheets/blog.css" />
    <script
      type="text/javascript"
      charset="utf-8"
      src="/ueditor/ueditor.config.js"
    ></script>
    <script
      type="text/javascript"
      charset="utf-8"
      src="/ueditor/ueditor.all.min.js"
    ></script>
    <script
      type="text/javascript"
      charset="utf-8"
      src="/ueditor/lang/zh-cn/zh-cn.js"
    ></script>
  </head>
  <body>
    <% if(userSession){%>
    <div class="container-fluid" style="background-color: #48525e">
      <header>
        <nav
          class="navbar"
          role="navigation"
          style="margin-bottom: -20px; height: 50px; z-index: 1000"
        >
          <!-- Brand and toggle get grouped for better mobile display -->
          <div class="navbar-header">
            <button
              type="button"
              class="navbar-toggle btn-sheng"
              data-toggle="collapse"
              data-target=".navbar-ex1-collapse"
            >
              <span class="sr-only">Toggle navigation</span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="/blog/detail" style="color: white"
              >微博首页</a
            >
          </div>

          <!-- Collect the nav links, forms, and other content for toggling -->
          <div class="navbar-collapse navbar-ex1-collapse hidden-xs">
            <div class="btn-group pull-right" style="margin-top: 1px">
              <button
                type="button"
                class="btn btn-default btn-lg btn-menu-icon"
              >
                <span class="glyphicon glyphicon-search"></span>
                <form
                  action=""
                  method="POST"
                  role="form"
                  class="blog_search btn-menu-hide wrak"
                >
                  <div class="form-group">
                    <label for="1"></label>
                    <input
                      type="text"
                      class="form-control"
                      name=""
                      id="1"
                      placeholder="Input..."
                      style="width: 204px; margin-top: -18px"
                    />
                    <span
                      class="glyphicon glyphicon-arrow-right"
                      style="
                        position: absolute;
                        top: 38px;
                        right: 9px;
                        color: #999;
                      "
                    ></span>
                  </div>
                </form>
              </button>

              <a href="/blogEdits" class="btn btn-default btn-lg btn-menu-icon"
                ><span class="glyphicon glyphicon-pencil"></span>
              </a>
              <button
                type="button"
                class="btnnod btn-default btn-lg btn-menu-icon"
              >
                <img src=<%=imgUrl%> alt="" width="25" height="25" >
                <div class="user_edit btn-menu-hide wrak">
                  <div class="user_edit_no" style="height: 146px">
                    <div style="margin-top: 15px; position: relative">
                      <a
                        style="position: absolute; top: 5px; left: 20px"
                        data-toggle="modal"
                        href="#modal_tx"
                        ><img src=<%=imgUrl%> alt="" width="100"
                        height="100"></a
                      >

                      <a
                        href="/blog/user"
                        style="position: absolute; top: 5px; right: 20px"
                        ><%=userSession %></a
                      >

                      <a
                        class="destroySession"
                        style="position: absolute; top: 55px; right: 0px"
                        >注销账户</a
                      >
                    </div>
                  </div>
                </div>
              </button>
            </div>
          </div>

          <div
            class="navbar-zdy collapse navbar-collapse navbar-ex1-collapse"
            id="navbar-zdy"
            style="background-color: white; padding-bottom: 20px"
          >
            <form action="" method="POST" role="form">
              <div class="form-group" style="position: relative">
                <label for=""></label>
                <input
                  type="text"
                  class="form-control"
                  name=""
                  id=""
                  placeholder="搜索博客"
                />
                <span
                  class="glyphicon glyphicon-arrow-right"
                  style="position: absolute; top: 29px; right: 9px; color: #999"
                ></span>
              </div>

              <a href="/blog/user" class="btn btn-primary btn-lg btn-block"
                >个人中心</a
              >
              <a href="" class="btn btn-primary btn-lg btn-block">发表博客</a>
              <!--<button type="submit" class="btn btn-primary">Submit</button>-->
            </form>
          </div>
        </nav>
      </header>
    </div>

    <div class="container">
      <div class="editBody">
        <div class="tab-content">
          <div class="tab-pane active" id="home">
            <h2>文章标题</h2>
            <hr />
            <span class="col-md-8 col-sm-6 col-xs-4">
              <input type="text" name="name" class="form-control "
              value=<%=contents[0]['title']%> title="" required="required"
              id="blog_title"> <input type="text" style="display: none"
              id="blog_cat" value=<%=contents[0]['cat']%>>
            </span>

            <div class="clearfix"></div>
            <hr />
            <h2>文章内容</h2>
            <hr />
            <textarea
              name="con_text"
              style="width: 500px; min-height: 420px; display: none"
            ></textarea>
            <script
              id="editor"
              type="text/plain"
              style="width: 1024px; height: 500px"
            ></script>
            <script>
              var ue = UE.getEditor("editor");
            </script>

            <button
              type="button"
              class="btn btn-primary"
              style="margin: 20px 0"
              id="context_update"
            >
              发表
            </button>
          </div>
        </div>
      </div>
    </div>

    <!--模态框-->
    <div class="modal fade" id="modal_tx">
      <div class="modal-dialog">
        <form action="/blog/detail" enctype="multipart/form-data" method="POST">
          <div class="modal-content">
            <div class="modal-header">
              <button
                type="button"
                class="close"
                data-dismiss="modal"
                aria-hidden="true"
              >
                &times;
              </button>
              <h4 class="modal-title">上传头像</h4>
            </div>
            <div class="modal-body">
              <input type="file" name="pic" />
              <input type="text" style="display: none" name="sRole" value="4" />
            </div>
            <div class="modal-footer">
              <button
                type="button"
                class="btn btn-default"
                data-dismiss="modal"
              >
                Close
              </button>
              <button type="submit" class="btn btn-primary">Submit</button>
            </div>
          </div>
        </form>
      </div>
    </div>

    <script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>
    <script src="/plugins/bootstrap/dist/js/bootstrap.min.js"></script>
    <script src="/javascripts/blog.js"></script>
    <script src="/javascripts/blogEdit.js"></script>
    <script>
      $(function () {
        ue.addListener("ready", function () {
          // editor准备好之后才可以使用
          //初始化编辑器内容
          $.ajax({
            type: "POST",
            url: "/blogEdits",
            data: {
              role: "6",
              title: $("#blog_title").val(),
              cat: $("#blog_cat").val(),
            },
            success: function (msg) {
              ue.setContent(msg.msg[0]["content"]);
            },
          });
          //        ue.setContent("sssss");
        });
      });
    </script>

    <%} else{ %>
    <h1>请返回<a href="/blog/user/login">登录</a></h1>
    <%}%>
  </body>
</html>
